@push('title')
    <title>票台列表</title>
@endpush
@push('style2')
<style>
    .layui-table-cell{
        height: auto;
        overflow:visible;
        text-overflow:inherit;
        white-space:normal;

    }
</style>
@endpush
@extends('layout.layer')
@section('content')

    <form class="layui-form layui-form-pane1" action="" lay-filter="first" style="margin-bottom: 15px">

        <div class="layui-input-inline">
            <label class="layui-form-label">店铺类型</label>
            <div class="layui-input-inline">
                <select name="status" lay-filter="interest">
                    <option value="0">所有</option>
                    <option value="1">携程</option>
                    <option value="2">去哪</option>
                    <option value="3">同程</option>
                    <option value="4">飞猪</option>
                </select>
            </div>
        </div>

        <div class="layui-input-inline">
            <label class="layui-form-label">店铺名称</label>
            <div class="layui-input-inline">
                <input type="text" name="name" maxlength="50" placeholder="店铺名称" autocomplete="off" class="layui-input" >
            </div>
        </div>


        <div class="layui-input-inline">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <select name="status" lay-filter="interest">
                    <option value="0">所有</option>
                    <option value="1">正常</option>
                    <option value="2">禁用</option>
                </select>
            </div>
        </div>

        <div class="layui-input-inline">
            <button class="layui-btn" id="search-btn" lay-submit lay-filter="*">搜索</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </form>

    <table id="test2" lay-filter="test2"></table>

@endsection
@push('script')
    <script>

        layui.use(['table','form'], function() {
            var $ = layui.$
                ,table = layui.table
                ,form = layui.form;


            table.render({
                id: 'test2'
                ,elem: '#test2'
                ,url: '/booking/ajaxLists'
                ,page: { //详细参数可参考 laypage 组件文档
                    curr: 1
                    ,groups: 20
                    ,first: 1
                    ,last: true
                    ,layout: ['limit', 'prev', 'page', 'next', 'count','refresh', 'skip'] //自定义分页布局
                }
                //,height: 300
                ,cellMinWidth: 80
                ,limit : 30
                //,skin: 'line'
                ,toolbar: false
                ,parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                    tableData =  res.data

                    return {
                        "code": res.errcode, //解析接口状态
                        "msg": res.errmsg, //解析提示文本
                        "count": res.meta.total, //解析数据长度
                        "data":res.data,
                    };


                }
                ,request: {
                    pageName: 'page' //页码的参数名称，默认：page
                    ,limitName: 'page_size' //每页数据量的参数名，默认：limit
                }
                ,cols: [[
                    {field: 'id', 'title':'ID'}
                    ,{field: 'name', 'title':'名称'}
                    ,{field: 'office', 'title':'office号',width:100}
                    ,{field: 'account', 'title':'接口账号'}
                    ,{field: 'pwd', 'title':'密码'}
                    ,{field: 'type', 'title':'类型',templet:function (row) {
                            switch (row.type){
                                case 1: return '携程';
                                case 2: return '去那';
                                case 3: return '同程';
                                case 4: return '飞猪';
                            }
                        }}
                    ,{field:'status', title:'状态',width: 200, templet: function (row) {
                            switch (row.status){
                                case 1: return '正常';
                                case 2: return '禁用';
                            }
                        }}
                    ,{field:'option', title:'操作',toolbar: '#result-option'}
                ]]

            });

            //监听提交
            form.on('submit(*)', function(data){

                table.reload('test2',{
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where:data.field
                });

                return false;
            });


        });
    </script>

@endpush